#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include<vector>
using namespace std;
int main()
{
    int n, q;
    cin >> n >> q;
    vector<int> arr(n + 1);
    for (int i = 1; i <= n; i++)
    {
        cin >> arr[i];
    }
    vector<long long> dp(n + 1);
    for (int i = 1; i <= n; i++)
    {
        dp[i] = dp[i - 1] + arr[i];
    }
    int i = 0;
    int r = 0;
    while (q--)
    {
        cin >> i >> r;
        cout << dp[r] - dp[i - 1] << endl;
    }
    return 0;
}
class Solution {
public:
    int pivotIndex(vector<int>& nums) {
        int n = nums.size();
        vector<int> lnums(n), rnums(n);
        for (int i = 1; i < n; i++)
            lnums[i] = lnums[i - 1] + nums[i - 1];
        for (int i = n - 2; i >= 0; i--)
            rnums[i] = rnums[i + 1] + nums[i + 1];

        for (int i = 0; i < n; i++)
            if (lnums[i] == rnums[i])
                return i;

        return -1;
    }
};
class Solution {
public:
    vector<int> productExceptSelf(vector<int>& nums) {
        int n = nums.size();
        vector<int> f(n), g(n);
        f[0] = g[n - 1] = 1;
        for (int i = 1; i < n; i++)
            f[i] = f[i - 1] * nums[i - 1];
        for (int i = n - 2; i >= 0; i--)
            g[i] = g[i + 1] * nums[i + 1];

        vector<int> ret;
        for (int i = 0; i < n; i++)
            ret[i] = f[i] * g[i];

        return ret;
    }
};